/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-30 11:01:15
 * @Description  : 题目收藏相关接口
 */

import type {
  QuestionFavCreateReq,
  QuestionFavPageRes,
  QuestionFavReq,
  QuestionFavUpdateReq
} from '@/types/questionFav'
import type {ErrorPaperReq,ErrorPaperRes} from '@/types/errorQuestion'
import request from '@/utils/request'

// 分页查询题目收藏接口
export const getQuestionFavByPage = (params?: QuestionFavReq) => {
  return request.get<QuestionFavPageRes>('/questionFav/list', { params })
}

// 分页查询试卷收藏接口
export const getPaperFavByPage = (params?: ErrorPaperReq) => {
  return request.get<ErrorPaperRes>('/questionFav/paperList', { params })
}

// 分页查询题目收藏接口
export const getAuthQuestionFavByPage = (params?: QuestionFavReq) => {
  return request.get<QuestionFavPageRes>('/questionFav/auth/list', { params })
}

// 添加题目收藏接口
export const createQuestionFav = (data: QuestionFavCreateReq) => {
  return request.post('/questionFav/create', data)
}

// 更新题目收藏接口
export const updateQuestionFav = (data: QuestionFavUpdateReq) => {
  return request.put('/questionFav/update', data)
}

// 题目收藏排序接口
export const sortQuestionFav = (questionFavIds: string[]) => {
  return request.put('/questionFav/sort', { questionFavIds })
}

// 题目收藏删除接口
export const delQuestionFav = (questionFavIds: string[], picCode?: string) => {
  return request.delete('/questionFav/delete', { data: { questionFavIds, picCode } })
}
